From: Colin Walters Date: Mon, 1 Aug 2016 01:33:15 +0000 (-0400) Subject: lib: Port away from gs_file_rename() X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~49^2~26 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/?a=commitdiff_plain;h=c671c1dd3e48927a7c545ade4dec80d7dff5beda;p=ostree.git lib: Port away from gs_file_rename() In one case, we already had relative fds and hence this was nicer. Unfortunately the other areas got uglier. More fd-relative porting to do later. Closes: #424 Approved by: giuseppe --- diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c index 6aa551ae..30edb7a5 100644 --- a/src/libostree/ostree-bootloader-grub2.c +++ b/src/libostree/ostree-bootloader-grub2.c @@ -408,9 +408,11 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, */ if (!ot_gfile_ensure_unlinked (self->config_path_efi, cancellable, error)) goto out; - if (!gs_file_rename (new_config_path, self->config_path_efi, - cancellable, error)) - goto out; + if (rename (gs_file_get_path_cached (new_config_path), gs_file_get_path_cached (self->config_path_efi)) < 0) + { + glnx_set_error_from_errno (error); + goto out; + } } ret = TRUE; diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 779c7dc1..d4feb7ed 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -795,9 +795,12 @@ selinux_relabel_var_if_needed (OstreeSysroot *sysroot, cancellable, error)) goto out; - if (!gs_file_rename (deployment_var_labeled_tmp, deployment_var_labeled, - cancellable, error)) - goto out; + if (rename (gs_file_get_path_cached (deployment_var_labeled_tmp), + gs_file_get_path_cached (deployment_var_labeled)) < 0) + { + glnx_set_error_from_errno (error); + goto out; + } } ret = TRUE; @@ -861,9 +864,11 @@ merge_configuration (OstreeSysroot *sysroot, else if (etc_exists) { /* Compatibility hack */ - if (!gs_file_rename (deployment_etc_path, deployment_usretc_path, - cancellable, error)) - goto out; + if (renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc") < 0) + { + glnx_set_error_from_errno (error); + goto out; + } usretc_exists = TRUE; etc_exists = FALSE; }